﻿using AutoMapper;
using MediatR;
using PersonnelManagement.Application.Command.ManpowerCommand;
using PersonnelManagement.Domain.PersonnelDomain;
using PersonnelManagement.Infrstructre.Interface;

namespace PersonnelManagement.Application.CommandHandler.ManpowerCommandHandler
{
    /// <summary>
    /// 人员档案添加
    /// </summary>
    public class AddManpowerCommandHandler : IRequestHandler<AddManpowerCommand, int>
    {
        IManpowerRepostiory mRep;
        IMapper mapper;

        public AddManpowerCommandHandler(IManpowerRepostiory mRep, IMapper mapper)
        {
            this.mRep = mRep;
            this.mapper = mapper;
        }

        public async Task<int> Handle(AddManpowerCommand request, CancellationToken cancellationToken)
        {
            return await mRep.Add(mapper.Map<Manpower>(request.AddDtos));
        }


    }
}
